/*
 * @(#) ServiceLocatorFactory.java 2011-4-21
 *
 * Copyright (c) 2011, HuaMei System Inc. All Rights Reserved.
 * Strong System Inc. CONFIDENTIAL
 */
package cn.strong.gweva.common.util;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;


/**
 * 
 *   
 * @author lilanfei
 * @version 1.0
 * @since 2011-4-21
 */
public class ApplicationContextHolder implements ApplicationContextAware
{
	private static BeanFactory factory;
	private static ApplicationContextHolder context;

	public static ApplicationContextHolder getInstance()
	{
		if (context == null) context = new ApplicationContextHolder();
		return context;
	}

	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
	{
		factory = applicationContext;
	}

	public Object getService(String serviceName)
	{
		return factory.getBean(serviceName);
	}
}
